//
//  AXMyOrderdetailVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/25.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyOrderdetailVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UIViewController+HBD.h"
#import "AXMyOrderdetailTopCell.h"
#import "AXMyOrderdetailCell.h"

@interface AXMyOrderdetailVC ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic , strong) UITableView *tableView;
@property (nonatomic , strong) NSArray<NSString *>  *names;
@property (nonatomic , strong) NSArray<NSString *>  *contents;

@end

@implementation AXMyOrderdetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
     self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self initData];
    [self creatView];
    [self setlayout];
    [self setupNavigationItems];
    
}

- (void)initData {
    
    self.names = @[@"发票种类",@"发票抬头",@"企业税号",@"商品总额",@"运费合计",@"订单总价",@"会员优惠",@"订单编号",@"支付方式",@"下单时间",@"支付时间",@"实付金额"];
    self.contents = @[@"企业",@"云南天质弘耕科技有限公司",@"854304363",@"¥98.00",@"¥12.00",@"¥132.00",@"-¥2.00",@"690149272",@"微信支付",@"2018-10-10",@"2018-10-10",@"¥132.00"];
    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
}

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)creatView {
    
    /** 表头创建 */
    self.tableView = [[UITableView alloc]init];
    /** 去掉cell线 */
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXMyOrderdetailTopCell class] forCellReuseIdentifier:[AXMyOrderdetailTopCell reuseID]];
     [self.tableView registerClass:[AXMyOrderdetailCell class] forCellReuseIdentifier:[AXMyOrderdetailCell reuseID]];
    [self.view addSubview:self.tableView];
    
    
}

- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, 0)
    .widthIs(Wi)
    .heightIs(Hi-Hn-44);
    
}

#pragma mark - tableviewDelegate & datasource

/** cell 高度  */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        
        return  280;
    }
    return 44;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 1;
    }
    
    return 12;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 0) {

        AXMyOrderdetailTopCell *cell = [tableView dequeueReusableCellWithIdentifier:[ AXMyOrderdetailTopCell reuseID] forIndexPath:indexPath];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

        return cell;

    }
   
    AXMyOrderdetailCell *cell = [tableView dequeueReusableCellWithIdentifier:[ AXMyOrderdetailCell reuseID] forIndexPath:indexPath];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.nameLabel.text = self.names[indexPath.row];
    cell.contentLabel.text = self.contents[indexPath.row];

    return cell;
 

}


@end
